#ifndef QCOLORPROPERTYEDITOR_H
#define QCOLORPROPERTYEDITOR_H

#include "QtPropertyExplorerLib.h"

#include <QWidget>
#include <QToolButton>
#include <QLineEdit>
#include <QLabel>
#include <QSpacerItem>

namespace QPE{

class QTPROPERTYEXPLORER_DLL_EXPORT QColorPropertyEditor : public QWidget
{
	Q_OBJECT

public:
	//! Constructor taking a widget as parent
	QColorPropertyEditor(QWidget *parent);

	//! Destructor
	virtual ~QColorPropertyEditor();


	//! Returns the color currently set
	QColor getColor();

	//! A little helper function generating an image to represent a color
	//! \param color The color to fill the image with
	//! \size The size of the generated pixmap
	//! \return Returns a QPixmap
	static QPixmap getColorPixmap(const QColor& color, unsigned int size = 16);

	//! A helper function to convert a color into a string.
	//! \param color The color to fill the image with
	//! \return The color as string, usually in the format [RRR, GGG, BBB] (AAA)
	static QString getColorString(const QColor& color);

	//! Needed for proper event handling
	bool eventFilter(QObject *obj, QEvent *ev);

signals:
	//! This is emitted, when the user changes the color
	void dataChangedByUser(const QColor &getColor, QColorPropertyEditor* editor);

public slots:
	//! Sets the color of the widget
	void setColor(const QColor &color_);

private slots:
	void onToolButtonClicked();

private:
	QColor Color;
	QToolButton* ToolButton;
	QLineEdit* Lineedit;
	QLabel* TextLabel;
	QLabel* ColorLabel;
	QSpacerItem* Spacer;
};

}

#endif // QFILEPROPERTYEDITOR_H
